var logo = document.querySelector(".logo")
var slogen = document.querySelector(".slogen")
var second_heard = document.querySelector(".nag")

second_heard.onmouseover = function () {
    logo.src = "images/logo_blue.png"
    slogen.src  = "images/slogen.png"
}
second_heard.onmouseout = function () {
    logo.src = "images/logo_white.png"
    slogen.src  = "images/slogen_fix.png"
}

var changePinyin = document.querySelector(".change-pinyin")

changePinyin .children[1].onclick = function () {
    var Selection = document.querySelector(".pinyin_city")
    Selection.children[1].style.display="inline"
}

// 渲染企业招聘
var conpany_list = document.querySelector(".conpany-list")
for(var i=0;i<6;i++){
    conpany_list.innerHTML+="<li>\n          " +
        "          <a href=\"\">\n                   " +
        "     <img src=\"../images/qucheng0222.gif\" alt=\"\">\n    " +
        "                </a>\n         " +
        "       </li>"
}


//更多地理位置
function areaChannelHomepageChangeTab(sName, oEvent)
{
    $("#area_channel_homepage_all").children().hide();
    $("#area_channel_homepage_list").children().removeClass("on");
    oEvent.addClass("on");
    // $("#area_channel_homepage_all").children("div[name='area_channel_div_" + sName + "']").show();
    $("div[name='area_channel_div_" + sName + "']").addClass("ondisplay")
}

function openAreaChannelHomepageDiv()
{
    if($(".citymore").is(":hidden"))
    {
        $(".citymore").show();
        areaChannelHomepageChangeTab('def', $("#area_channel_homepage_list").children(":first"));
        $("#area_channel_homepage_more").addClass("on");
    }
    else
    {
        $(".citymore").hide();
        $("#area_channel_homepage_more").removeClass("on");
    }
}

getLatest()

/* 加载最新的10条招聘记录*/
function getLatest() {
    console.log("getget ....");

    $.ajax({
        type:"GET",
        url:"/job/latest",
        datatype:"json",
        success:function (result) {
            var jobList = result.data
            console.log(jobList);

            //渲染职位
            var job_list = $(".job-list")
            for (var i=0;i<jobList.length;i++){
                var jobName = jobList[i].jobName
                var jobCity = jobList[i].jobCity
                var jobYear = jobList[i].jobYear
                var jobDegree = jobList[i].jobDegree


                var jobele ="<li>\n          " +
                    "          <p class=\"job-info\">\n           " +
                    "             <span class=\"name\">"+jobName+"</span>\n      " +
                    "                  <span class=\"salary\">20-40K 15薪</span>\n        " +
                    "            </p>\n            " +
                    "        <p class=\"job-text\">\n           " +
                    "             <span>"+jobCity+"</span> |\n              " +
                    "          <span>"+jobYear+"</span> |\n                 " +
                    "       <span>"+jobDegree+"</span>\n                    </p>\n     " +
                    "               <div class=\"user\">\n                   " +
                    "     <div class=\"user-info\">\n                     " +
                    "       <a href=\"javascript:;\">\n            " +
                    "                    <img src=\"../images/avatar_14.png\" alt=\"\">\n              " +
                    "                  <span class=\"company-name\">腾讯</span>\n                 " +
                    "               <span class=\"user-name\">金先生\n                     " +
                    "          <span class=\"vline\"></span>\n                         " +
                    "      组长</span>\n                                <i></i>\n\n                   " +
                    "         </a>\n\n                        </div>\n              " +
                    "      </div>\n\n            " +
                    "    </li>"

                job_list.append(jobele)

            }

            //渲染公司
        }
    })
}

$(".search-btn").click(function () {
   var kw = $(".search-text").val()
    location.href = "/job/job_all.jsp?kw="+kw
})



